package com.caizi.socket.imagetool;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Start {

    public static void main(String... strs) throws Exception {

        Map<String, File> imagesMap = new HashMap<String, File>();
        File destSheet = new File("D:/货号.xls");
        List<String> productIds = ExcelOper.readSheet(destSheet);
        // for (int j = 0; j < productIds.size() / 10; j++) {
        // for (int i = 0; i < 10; i++) {
        // Runnable download = new Download(httpUrl, productIds.get(j * 10 +
        // i));
        // Thread thread = new Thread(download);
        // thread.start();
        for (String productId : productIds) {
            String httpUrl = "http://s.taobao.com/search?q=" + productId + "&sort=sale-desc&style=grid&s=0";
            Map<String, File> imageMap = ImageOper.downloadImage(httpUrl, productId);
            if (null != imageMap) {
                imagesMap.putAll(imageMap);
            }
        }
        ExcelOper.writeSheet(destSheet, imagesMap);
    }

}
